<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>办公室：导游领队家庭成员</title>
	<jsp:include page="/com/common/_js.jsp"></jsp:include>
	<script type="text/javascript">
	$(function(){
		$("#addfd").click(function(){
			var display=$("#form-guidefm").css("display");
			if(display=="none"){
				$("#form-guidefm").css("display","");
			}else{
				var size=$("fieldset").size();
				$("<fieldset id='g"+size+"'></fieldset>").append($("#g0").html()).appendTo($("form")).after($(":submit"));
				
				$("label","#g"+size).each(function(){
					$(this).attr("for",$(this).attr("for").replace("0",size));
				});
				
				$("input","#g"+size).each(function(){
					$(this).attr("id",$(this).attr("id").replace("0",size));
					$(this).attr("name",$(this).attr("name").replace("0",size));
				});
				
				$(".datepicker").removeClass("hasDatepicker").datepicker({changeMonth: true,changeYear: true});				
			}
		});
		
		$("#cancel").click(function(){
			var size=$("fieldset").size()-1;
			if(size>0){
				$("#g"+size).remove();
			}else{
				$("#form-guidefm").css("display","none");
			}
		});
		
	});
	</script>
</head>
<body>
	<div id="web">
		<div id="head"></div>
		<div id="body">
			<div class="container-fluid">
			    <div class="row-fluid">
				    <div class="span2">
				    <jsp:include page="_left.jsp"></jsp:include>
				    </div>
				    <div class="span10">
				    <div class="left-bar"><i class="icon-flag icon-white"></i> 导游领队家庭成员</div>
				 		<s:if test="guidefmList==null">
							<script type="text/javascript">
							$(function(){$("#form-guidefm").show();});
							</script>
						</s:if>
						<s:else>
							<table class="table table-condensed">
								  <tr>
								    <th>家庭成员</th>
								    <th>姓名</th>
								    <th>生日</th>
								    <th>工作单位</th>
								    <th>职业</th>
								    <th>联系电话</th>
								  </tr>
								  <s:iterator value="guidefmList">
									  <tr>
									    <td><s:property value="relative"/></td>
									    <td><s:property value="name"/></td>
									    <td><s:date name="birthday" format="yyyy-MM-dd"/></td>
									    <td><s:property value="workUnit"/></td>
									    <td><s:property value="career"/></td>
									    <td><s:property value="phonenum"/></td>
									  </tr>
								  </s:iterator>
								</table>
						</s:else>
					
							<a id="addfd" class="a-button">添加成员</a>
							<a id="cancel" class="a-button">取消</a>
							<br>
						<div id="form-guidefm" style="display: none;">
							<s:form action="guidefmAction!insertGuidefm.jspa" namespace="/officer">
								<fieldset id="g0">
									<s:hidden name="guidefmList[0].guideId" value="%{guideId}"></s:hidden>
									<div class="field">
										<label for="guidefmAction_guidefmList_0__name">姓名:</label>
										<input type="text" id="guidefmAction_guidefmList_0__name" name="guidefmList[0].name">
									</div>
									<div class="field">
										<label for="guidefmAction_guidefmList_0__relative">成员关系:</label>
										<input type="text" id="guidefmAction_guidefmList_0__relative" name="guidefmList[0].relative">
									</div>
									<div class="field">
										<label for="guidefmAction_guidefmList_0__birthday">生日:</label>
										<input type="text" id="guidefmAction_guidefmList_0__birthday" name="guidefmList[0].birthday" class="datepicker">
									</div>
									<div class="field">
										<label for="guidefmAction_guidefmList_0__workUnit">工作单位:</label>
										<input type="text" id="guidefmAction_guidefmList_0__workUnit" name="guidefmList[0].workUnit">
									</div>
									<div class="field">
										<label for="guidefmAction_guidefmList_0__career">职业:</label>
										<input type="text" id="guidefmAction_guidefmList_0__career" name="guidefmList[0].career">
									</div>
									<div class="field">
										<label for="guidefmAction_guidefmList_0__phonenum">联系电话:</label>
										<input type="text" id="guidefmAction_guidefmList_0__phonenum" name="guidefmList[0].phonenum">
									</div>
								</fieldset>
								
								<div class="button">
									<s:submit value="提交"></s:submit>
								</div>
							</s:form>
						</div>
				    </div>
			    </div>
			</div>
		</div>
		<div id="foot"></div>
	</div>
</body>
</html>